package entity.enums;

/**
 * @author zhouwz
 * @date 2020/8/18 13:56
 */
public enum HikDeviceStatus {
    /**
     * 设备状态
     */
    STATUS_1(1, "设备空闲"),
    STATUS_2(2, "已完成任务"),
    STATUS_3(3, "控制指令执行中"),
    STATUS_4(4, "弧线行走中"),
    STATUS_5(5, "设备的举升机构正在执行动作"),
    STATUS_6(6, "设备正在进行自主调整"),
    STATUS_7(7, "设备正在充电"),
    STATUS_8(8, "设备正在进行电池充满维护"),
    STATUS_9(9, "设备正在进行动态绕障"),
    STATUS_A(10, "设备正在巡线中（牵引车使用）"),
    STATUS_B(11, "设备强制完成当前任务 "),
    STATUS_41(65, "前方遇障"),
    STATUS_42(66, "后方遇障"),
    STATUS_43(67, "左侧遇障"),
    STATUS_44(68, "右侧遇障"),
    STATUS_45(69, "弧线移动时前方遇障"),
    STATUS_46(70, "弧线移动时后方遇障"),
    STATUS_47(71, "弧线移动时左侧遇障"),
    STATUS_48(72, "弧线移动时右侧遇障"),
    STATUS_81(129, "设备收到暂停指令，并处于暂停状态"),
    STATUS_82(130, "设备处于异常中，如拍急停，或硬件出错等"),
    STATUS_83(131, "异常偏航"),
    STATUS_84(132, "货架偏角过大"),
    STATUS_C1(193, "平台指令错误"),
    //        各大厂商公用状态
    STATUS_100(256, "背货未识别（背货架移动过程中，扫不到货码）"),
    STATUS_101(257, "货码无法识别（举升前扫不到货码）"),
    STATUS_102(258, "货码不匹配"),
    STATUS_103(259, "举升异常"),
    STATUS_104(260, "货架角度偏移过大"),
    STATUS_105(261, "货架位置偏移过大"),
    STATUS_106(262, "货架堵转"),
    STATUS_107(263, "矩形托盘，零位检测失败"),
    STATUS_140(320, "充电桩异常"),
    STATUS_141(321, "电量无增加"),
    STATUS_142(322, "充电站充电过程中失联"),
    STATUS_143(323, "充电站未连接"),
    STATUS_180(384, "SLAM 定位失败"),
    STATUS_1C0(448, "空车状态检测异常,未执行取货相关指令，但设备上的传感器检测到货物(也可能非货物)"),
    STATUS_1C1(449, "载货状态检测异常,载货情况下未执行放货相关指令，但设备上的传感器检测不到货物"),
    STATUS_1C2(450, "设备自主调整失败, 如叉车自主规划路径调整时，规划路径失败等"),
    STATUS_2C0(704, "设备处于显示屏操作中"),
    //以下为海康私有状态
    STATUS_300(768, "区域锁定失败"),
    STATUS_301(769, "旋转申请空间锁定暂时失败"),
    STATUS_302(770, "旋转申请空间锁定永久失败"),
    STATUS_303(771, "地图切换点地码未识别"),
    STATUS_304(772, "SLAM 地图配置中"),
    STATUS_305(773, "货架位置不可信"),
    STATUS_306(774, "外力下放"),
    STATUS_307(775, "设备不在锁定区"),
    STATUS_308(776, "下放重试失败"),
    STATUS_309(777, "货架摆歪"),
    STATUS_30A(778, "举升电池电量太低"),
    STATUS_30B(779, "未背货架举升在上"),
    STATUS_30C(780, "栈板识别失败"),
    STATUS_340(832, "非轴向移动"),
    STATUS_341(833, "弧线中间点参数数量错误"),
    STATUS_342(834, "非旋转地码上转弯任务"),
    STATUS_343(835, "任务角度异常"),
    STATUS_344(836, "传感器校验中或 MCU 未 READY"),
    STATUS_345(837, "举升不在低位空车移动"),
    STATUS_346(838, "原地举升位置偏差大"),
    STATUS_347(839, "禁止货架下转弯任务"),
    STATUS_348(840, "货架信息缺失"),
    STATUS_349(841, "充电指令角度错误"),
    STATUS_380(896, "后退角度偏大"),
    STATUS_381(897, "待机模式中"),
    STATUS_382(898, "低功耗模式中"),
    STATUS_383(899, "休眠模式中"),
    STATUS_384(900, "异常休眠模式"),
    STATUS_385(901, "电量过低预警"),
    OTHER(0, "其他异常");

    HikDeviceStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    private final int code;
    private final String message;

    public static HikDeviceStatus getHikDeviceStatus(Integer code) {
        for (HikDeviceStatus item : HikDeviceStatus.values()) {
            if (code.equals(item.getCode())) {
                return item;
            }
        }
        return STATUS_1;
    }
}
